<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="${path}/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${path}/static/css/font-awesome.min.css">
    <link rel="stylesheet" href="${path}/static/css/main.css">
    <style>
        .tree li {
            list-style-type: none;
            cursor:pointer;
        }
    </style>
</head>

<body>

<jsp:include page="${path}/static/nav.jsp"></jsp:include>

<div class="container-fluid">
    <div class="row">

        <jsp:include page="${path}/static/left.jsp"></jsp:include>

        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <ol class="breadcrumb">
                <li><a href="${path}/main">首页</a></li>
                <li><a href="${path}/permission/index">数据列表</a></li>
                <li class="active">修改</li>
            </ol>
            <div class="panel panel-default">
                <div class="panel-heading">表单数据<div style="float:right;cursor:pointer;" data-toggle="modal" data-target="#myModal"><i class="glyphicon glyphicon-question-sign"></i></div></div>
                <div class="panel-body">
                    <form id="userForm" role="form">
                        <input type="hidden" name="permissionid" id="permissionid" value="${permission.permissionid}"/>
                        <div class="form-group">
                            <label for="permissionname">权限名称</label>
                            <input type="text" class="form-control" id="permissionname" name="permissionname" value="${permission.permissionname}">
                        </div>
                        <div class="form-group">
                            <label for="permissionpath">权限路径</label>
                            <input type="text" class="form-control" id="permissionpath" name="permissionpath" value="${permission.permissionpath}">
                        </div>
                        <button type="button" id="btnupdate" class="btn btn-success"><i class="glyphicon glyphicon-edit"></i> 修改</button>
                        <button type="button" class="btn btn-danger"><i class="glyphicon glyphicon-refresh"></i> 重置</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${path}/static/jquery/jquery-2.1.1.min.js"></script>
<script src="${path}/static/bootstrap/js/bootstrap.min.js"></script>
<script src="${path}/static/script/docs.min.js"></script>
<script src="${path}/static/layer/layer.js"></script>
<script type="text/javascript">
    $(function () {
        $(".list-group-item").click(function(){
            if ( $(this).find("ul") ) {
                $(this).toggleClass("tree-closed");
                if ( $(this).hasClass("tree-closed") ) {
                    $("ul", this).hide("fast");
                } else {
                    $("ul", this).show("fast");
                }
            }
        });
    });

    $("#btnupdate").click(function () {
        $.ajax({
            url:"${path}/permission/update",
            method:"post",
            data:$("#userForm").serialize(),
            dataTyep:"json",
            error:function(){
                alert("失败");
            },
            success:function (obj) {
                if("true"==obj){
                    layer.msg("修改成功", {time:1000, icon:6, shift:4});
                    window.location.href="${path}/user/index";
                }else{
                    layer.msg("修改失败", {time:1000, icon:5, shift:6});
                    window.location.href="${path}/user/index";
                }
            }
        });
    })

</script>
</body>
</html>
